<?php
    require('common.php');

    // Error check
    checkCsrfGuard();
    $db = new Database();
    $user = getUser($db);
    if($user['group'] == 0)
        throw new Exception('Bad request.');
    
    // Clear cookie
    setcookie('user_id', '', time() - 3600);
    setcookie('password', '', time() - 3600);
	
    // Logout successfull
	redirect('login.php');
?>